from PIL import Image

# 打开两张图片
image1 = Image.open('图片1.png')  # 替换为你的第一张图片路径
image2 = Image.open('图片2.png')  # 替换为你的第二张图片路径

# 拼接图片
combined_width = image1.width + image2.width
combined_height = max(image1.height, image2.height)
new_image = Image.new('RGB', (combined_width, combined_height))

# 将图片粘贴到新图像上
new_image.paste(image1, (0, 0))
new_image.paste(image2, (image1.width, 0))

# 保存拼接后的图片
new_image.save('combined_image.png')
new_image.show()
